<?php
/**
 * @title 100. 相同的树 - 递归
 * @author start2004
 */

// ini_set("memory_limit", "128M");

class Solution {

    /**
     * @param TreeNode $p
     * @param TreeNode $q
     * @return Boolean
     */
    function isSameTree($p, $q) {
        if($p === null AND $q === null){
            return true;
        } elseif($p ===  null OR $q === null) {
            return false;
        } elseif($p->val != $q->val){
            return false;
        } else {
            return self::isSameTree($p->left, $q->left) AND self::isSameTree($p->right, $q->right);
        }
    }
}



/**
 * @url http://127.0.0.1/leetcode/202008/2020.08.07_9.php
 */
$datas = [
    [[1,2,3], [1,2,3]],
];

include_once dirname(__DIR__) . DIRECTORY_SEPARATOR ."xhprof.php";
$xhprof = new Xhprof();
foreach ($datas as $data){
    var_dump($data);

    $obj = new Solution();
    $result = $obj->isSameTree($xhprof->tree($data[0]), $xhprof->tree($data[1]));
    var_dump($result);
    echo str_repeat("<br>", 3);
}
$xhprof->end();
